package everyday.apr;

/**
 * 1672. 最富有客户的资产总量
 */
public class Day14 {
    public static void main(String[] args) {
        System.out.println(maximumWealth(new int[][]{new int[]{1, 2, 3}, new int[]{3, 2, 1}}));
        System.out.println(maximumWealth(new int[][]{new int[]{1, 5}, new int[]{7, 3}, new int[]{3, 5}}));
    }

    /**
     * 双层for遍历
     * 数组求和，可以用Arrays.stream(array).sum();但效率不如for循环
     */
    public static int maximumWealth(int[][] accounts) {
        int max = 0;
        for (int[] account : accounts) {
            int sum = 0;
            for (int i : account) {
                sum += i;
            }
            max = Math.max(max, sum);
        }
        return max;
    }
}
